package Demo;

class Solution1 {
    public void merge(int[] nums1, int m, int[] nums2, int n) {
        int[] arrays = new int[n+m];
        int i = 0;
        int j = 0;
        int size = 0;
        while(i < m && j < n) {
            if(nums1[i] > nums2[j]) {
                arrays[size++] = nums1[i];
                i++;
            }else {
                arrays[size++] = nums1[j];
                j++;
            }
        }
        while(i < m) {
            arrays[size++] = nums1[i];
            i++;
        }
        while(j < m) {
            arrays[size++] = nums1[j];
            j++;
        }
        nums1 = arrays;
    }
}